package edu.zju.gis.cky.controller;

import com.github.pagehelper.PageInfo;
import edu.zju.gis.cky.entity.Meta;
import edu.zju.gis.cky.entity.dto.InputDTO;
import edu.zju.gis.cky.entity.dto.UpdateDTO;
import edu.zju.gis.cky.service.MetaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Zhou Yuquan
 * @version 1.0, 2021-11-17
 */
@RequestMapping("/meta")
@RestController
public class MetaController {

    @Autowired
    private MetaService service;

    @GetMapping("/get/{id}")
    public Meta getById(@PathVariable long id) {
        return service.getById(id);
    }

    @GetMapping("/get/all")
    public PageInfo<Meta> getAll(@RequestParam int pageNum, @RequestParam int pageSize) {
        return service.getAll(pageNum, pageSize);
    }

    @GetMapping("/get/gradation")
    public PageInfo<Meta> getByGradation(@RequestParam int pageNum, @RequestParam int pageSize, @RequestParam String gradation) {
        return service.getByGradation(pageNum, pageSize, gradation);
    }

    @PostMapping("/edit")
    public void editById(@RequestBody UpdateDTO updateDTO) {
        service.editById(updateDTO);
    }

    @PostMapping("/input")
    public void inputByType(@RequestBody InputDTO inputDTO) {
        service.inputByType(inputDTO);
    }

    @GetMapping("/output/{id}")
    public void outputByType(@PathVariable long id) {
        service.outputByType(id);
    }
}
